//迭代器
function* walk(str){
    let part ='';
    // 终结符
    let terminals=['.','-']
    for(var i=0;i<str.length;i++){
        if(terminals.includes(str[i])){
            // 终结符
            yield part;
            part='';
        }else{
            part+=str[i];
        }
    }
    if(part){
        yield part;
    }
}

const iterator1 =  walk('1.5.6-alpha.1');
for(const item of iterator1){
    console.log(item)
}
const iterator2 =  walk('1.5.6-alpha.1');
let item1 = iterator2.next();
console.log(item1)